package com.le.buddha.controller;

import com.le.buddha.service.IUserGoodService;
import com.le.buddha.mobile.UserGood;
import com.le.buddha.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userGood")
public class UserGoodController {
    @Autowired
    public IUserGoodService userGoodService;





    /**
     * 新增信息
     * @param userGood  传递的实体
     * @return Ajaxresult转换结果
     */
    @RequestMapping(value="/saveUserGood")
    public Response saveUserGood(UserGood userGood){


             userGoodService.save(userGood);

            return Response.success(userGood);

    }

    /**
    * 删除信息
    * @param id
    * @return
    */
    @RequestMapping(value="delete/{id}")
    public Response deleteUserGood(@PathVariable("id") Long id){

         userGoodService.removeById(id);
            return  Response.success();

    }

    /**
    *  根据id查询对象
    * @return
    */

    @RequestMapping(value = "find/{id}")
    public Response getUserGood(@PathVariable("id")Long id)
    {
        return  Response.success(userGoodService.getById(id));
    }


    /**
    * 查询所有信息
    * @return
    */


    @RequestMapping(value = "/listUserGood")
    public  Response listUserGood(){

        return  Response.success(userGoodService.list());
    }


}